

package com.maoshi.shop.security.multishop.model;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Collections;

/**
 * 用户详细信息
 *
 * @author
 */
@Data
public class MaoshiShopUser implements UserDetails {

	/**
	 * 用户ID
	 */
	private String userId;

	/**
	 * 店铺id
	 */
	private Long shopId;

	private boolean enabled;

	private String password;

	private String username;

	public MaoshiShopUser(){

	}

	@Override
	public Collection<GrantedAuthority> getAuthorities() {
		return Collections.emptyList();
	}

	@Override
	public String getPassword() {
		return this.password;
	}

	@Override
	public String getUsername() {
		return "shop_" + this.username;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return this.enabled;
	}

	public String getRealUsername() {
		return this.username;
	}
}
